﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using PHMEE.EnergyEfficiency;

namespace PHMEE.Controllers.CBM;

/// <summary>
/// 船舶能效
/// </summary>
[Route("api/cbm/vessel-ee-info")]
public class VesselEEInfoController : PHMEEController, IVesselEEInfoAppService
{
    private readonly IVesselEEInfoAppService _vesselEEInfoAppService;

    public VesselEEInfoController(IVesselEEInfoAppService vesselEEInfoAppService)
    {
        _vesselEEInfoAppService = vesselEEInfoAppService;
    }

    // /// <summary>
    // /// 船舶即时能效信息
    // /// </summary>
    // /// <param name="vesselId"></param>
    // /// <returns></returns>
    // [HttpGet]
    // // [ProducesResponseType(typeof(VesselDto), StatusCodes.Status200OK)]
    // public Task<VesselEEInfoDto> CurrentEEInfoAsync(Guid vesselId)
    // {
    //     return _vesselEEInfoAppService.CurrentEEInfoAsync(vesselId);
    // }

    /// <summary>
    /// 年度 EEOI
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="year"></param>
    /// <returns></returns>
    [Route("AnnualEEOI")]
    [HttpGet]
    public Task<EEOIDto> AnnualEEOI(Guid vesselId,
        int? year)
    {
        return _vesselEEInfoAppService.AnnualEEOI(vesselId, year);
    }

    /// <summary>
    /// 当前航次 EEOI
    /// </summary>
    /// <param name="vesselId"></param>
    /// <returns></returns>
    [Route("CurrentVoyageEEOI")]
    [HttpGet]
    public Task<EEOIDto> CurrentVoyageEEOI(Guid vesselId)
    {
        return _vesselEEInfoAppService.CurrentVoyageEEOI(vesselId);
    }

    /// <summary>
    /// EEOI 能效对比
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="startDate"></param>
    /// <param name="endDate"></param>
    /// <returns></returns>
    [Route("EEOICompareData")]
    [HttpGet]
    public Task<IReadOnlyList<EEOICIIComparisonTimeSeriesDatum>> EEOICompareDataAsync(Guid vesselId,
        DateTime startDate, DateTime endDate)
    {
        return _vesselEEInfoAppService.EEOICompareDataAsync(vesselId, startDate, endDate);
    }

    /// <summary>
    /// EEOI 能效对比（范围为年）
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="year"></param>
    /// <returns></returns>
    [Route("EEOICompareDataByYear")]
    [HttpGet]
    public Task<IReadOnlyList<EEOICIIComparisonTimeSeriesDatum>> EEOICompareDataByYearAsync(Guid vesselId, int year)
    {
        return _vesselEEInfoAppService.EEOICompareDataByYearAsync(vesselId, year);
    }

    /// <summary>
    /// 能效查询-所选时间段的能效信息
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="startDate"></param>
    /// <param name="endDate"></param>
    /// <returns></returns>
    [Route("DateRangeEEData")]
    [HttpGet]
    public Task<DateRangeEEDataDto> DateRangeEEData(Guid vesselId,
        DateTime startDate, DateTime endDate)
    {
        return _vesselEEInfoAppService.DateRangeEEData(vesselId, startDate, endDate);
    }
}